package com.luo.shop.service.impl;

import com.luo.shop.dao.CategoryDao;
import com.luo.shop.pojo.Category;
import com.luo.shop.service.CategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CategoryServiceImpl implements CategoryService {
    @Autowired
    private CategoryDao categoryDao;

    public List<Category> selectAll(){
        return categoryDao.selectAll();
    }

    public Category queryById(Long id) {
        Category category = categoryDao.selectByPrimaryKey(id);
        category.setParentCategory(categoryDao.selectByPrimaryKey(category.getPid()));
        return category;
    }

}
